package com.cn.el;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.cn.domain.User;

public class ElServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		request.setAttribute("error", "这是一个错误！");
		String str = (String) request.getAttribute("param");
		request.setAttribute("param", str);
		
		List<String> list = new ArrayList<String>();
		list.add("hello");
		list.add("world");
		list.add("java");
		request.setAttribute("list", list);
		
		User u1 = new User();
		u1.setId(1);
		u1.setCategory("java");
		User u2 = new User();
		u2.setId(2);
		u2.setCategory("ios");
		User u3 = new User();
		u3.setId(3);
		u3.setCategory("文学");
		
		List<User> list02 = new ArrayList<User>();
		list02.add(u1);
		list02.add(u2);
		list02.add(u3);
		request.setAttribute("list02", list02);
		
		request.setAttribute("p", u1);
		
		request.getRequestDispatcher("/el02/test01.jsp").forward(request, response);
	}

}
